package com.learn.grpc.nameserver;

import io.grpc.Server;
import io.grpc.ServerBuilder;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class NsGrpcServer9091 {

    public static void main(String[] args) throws Exception{

        int serverPort = 9091;

        //1. 创建 server 构造器
        ServerBuilder<?> serverBuilder = ServerBuilder.forPort(serverPort);

        //2. 添加暴露的服务
        serverBuilder.addService(new NsGrpcImpl(serverPort));

        //3. 构建 Server
        Server server = serverBuilder.build();

        //4. 启动服务
        server.start();

        // 等待停止
        server.awaitTermination();

    }
}
